<?php

/**
 * 问题反馈
 */

namespace app\api\controller;


use app\common\controller\ApiController;
use app\common\lib\RespCode;
use think\Exception;
use app\api\model\UserProblem as UserProblemModel;

class UserProblem extends ApiController {

    protected $resubmitLock = ['submit'];

    /**
     * 提交反馈
     * @return false|string
     */
    public function submit() {
        try {
            $params = $this->checkParams('content');
            if ($params === false) {
                return $this->resErr();
            }
            $re = UserProblemModel::add($params);
            if (!$re) {
                throw new Exception('操作失败', RespCode::QUERY_ERR);
            } else {
                return $this->resData('操作成功', []);
            }
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }
}
